package ly.sjun.design.builder_pattern;

import ly.sjun.design.builder_pattern.food.Packing;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: Meal
 * @Author: ly
 * @Date: 2023/2/2-10:28
 * @Description 点单
 **/
public class Meal {

    private List<FruitTea> teas = new ArrayList<>();

    private Packing packing;

    public void add(FruitTea tea) {
        teas.add(tea);
    }

    public void setPacking(Packing packing){
        this.packing = packing;
    }

    public float getTotal() {
        float sum = 0f;
        for (FruitTea item : teas) {
            sum += item.price();
        }
        sum+= packing.price();
        return sum;
    }

    public void showItem() {
        for (FruitTea item : teas) {
            System.out.print("添加了 : " + item.name());
            System.out.print(", 温度 : " + item.temperature().temperature());
            System.out.println(", 价格 : " + item.price());
        }
        System.out.println("食用方式："+packing.packing());
    }

}
